package com.jiezuo.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiezuo.auth.entity.Position;
import com.jiezuo.auth.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description 岗位
 * @author 庞留杰
 * @date 2024/03/01 15:03
 * @version V1.0
 **/
public interface PositionMapper extends BaseMapper<Position> {

    IPage<Position> findList(@Param("page") Page page, @Param("entity") Position position);

    List<Position> findList(@Param("entity") Position position);

    @Select("SELECT su.id,su.user_code,su.user_name,su.real_name,su.positions,sd.name AS main_dept_name FROM sys_user su " +
            "LEFT JOIN sys_depart sd ON sd.is_delete=0 AND sd.id=su.main_dept " +
            "WHERE su.is_delete=0 AND FIND_IN_SET(#{position_id},su.positions) ")
    List<User> findUserListByPositionId(@Param("position_id") String position_id);

}
